package com.bicon.botu.mall.goods.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.bicon.botu.mall.goods.dto.OrderVerifyDto;
import com.bicon.botu.mall.goods.dto.ProductSalesVolumeDTO;
import com.bicon.botu.mall.goods.entity.ProductRepertory;
import com.bicon.botu.mall.goods.vo.ProductRepertoryInfo;
import com.bicon.botu.mall.goods.vo.ProductSkuVo;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 产品库存 服务类
 * </p>
 *
 * @author 孙永刚
 * @since 2017-07-20
 */
public interface IProductRepertoryService extends IService<ProductRepertory> {

    /**
     * 分页获取仓库信息
     * @param infoPage
     * @param map
     * @return
     */
    Page<ProductRepertoryInfo> getPage(Page<ProductRepertoryInfo> infoPage, Map<String,String> map);

    /**
     * 获取该商品sku
     * @param productId
     * @return
     */
    List<ProductSkuVo> getProductSku(String productId);

    /**
     * 获取该商品sku
     * @param productId
     * @return
     */
    List<ProductSkuVo> getProductRepertorySku(String productId);

    /**
     *
     * @return
     */
    Map<String,Object> repertoryTotal();

    /**
     * 添加库存数量
     * @param num   数量
     * @param repertoryId Id
     * @return
     */
    boolean updateNumberById(int type, int num, String repertoryId);

    /**
     * 回退库存
     * @param repertoryList 更新数量
     * @return
     */
    boolean updateNumber(List<OrderVerifyDto> repertoryList);

    /**
     * 添加销量
     * @param repertoryList
     * @return
     */
    boolean addSalesByList(List<OrderVerifyDto> repertoryList);

    /**
     * 添加销量Id
     * @param num
     * @param repertoryId
     * @return
     */
    boolean addSalesById(int num, String repertoryId);

    /**
     * 商品销量top10
     * @return
     */
    List<ProductSalesVolumeDTO> salesVolumeTop10(Integer type,String startTime, String endTime);


    /**
     * 修改sku库存数量
     *
     * @param stringJson
     * @param productRepertoryController
     * @return
     *//*
    @RequestMapping(value = "updateRepertoryNum", method = RequestMethod.POST)
    default BaseResult updateRepertoryNum(@RequestParam("StringJson") String stringJson, ProductRepertoryController productRepertoryController) {
        List<ProductSkuVo> list = JSONObject.parseArray(stringJson, ProductSkuVo.class);
        List<ProductRepertory> updateList = new ArrayList<>();
        if (list.size() > 0) {
            for (ProductSkuVo vo : list) {
                ProductRepertory repertory = new ProductRepertory();
                repertory.setProductId(vo.getRepertoryId());
                repertory.setProductNum(vo.getSurplusNum());
                updateList.add(repertory);
            }
            updateBatchById(updateList);
        }
        return productRepertoryController.sendResult(GoodsConstants.RESPONSE_CODE_200, GoodsConstants.RESPONSE_MESSAGE_200);
    }
*/
    // List<ProductRepertoryInfo> getProductInfo(Page<ProductRepertoryInfo> infoPage, Map<String,String> map);

}
